]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Get some values outside the children loop when allocating
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 25 Feb 2021 11:13:21 +0000 (12:13 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 9 Mar 2021 15:40:49 +0000 (15:40 +0000)
It turned out that getting properties and saving them to a variable
outside of loops instead of accessing them everytime inside the loop can
have significant impact on performance, so do that in Workspaces
vfunc_allocate().

Here the impact is not that large, about 0.05 ms with 20 open windows,
that still seems worth it though.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1743>

js/ui/workspace.js

index 8a273e865ec737214e645ea3f24660308791c53d..f11f546f1e0393894466efb51321559214e3897a 100644 (file)
@@ -609,7 +609,12 @@ var WorkspaceLayout = GObject.registerClass({
                 this._windowSlots = this._getWindowSlots(box.copy());
         }
 
-        const allocationScale = containerBox.get_width() / this._workarea.width;
+        const workareaX = this._workarea.x;
+        const workareaY = this._workarea.y;
+        const workareaWidth = this._workarea.width;
+        const stateAdjustementValue = this._stateAdjustment.value;
+
+        const allocationScale = containerBox.get_width() / workareaWidth;
 
         const workspaceBox = new Clutter.ActorBox();
         const layoutBox = new Clutter.ActorBox();
@@ -628,16 +633,16 @@ var WorkspaceLayout = GObject.registerClass({
 
             if (windowInfo.metaWindow.showing_on_its_workspace()) {
                 workspaceBox.set_origin(
-                    child.boundingBox.x - this._workarea.x,
-                    child.boundingBox.y - this._workarea.y);
+                    child.boundingBox.x - workareaX,
+                    child.boundingBox.y - workareaY);
                 workspaceBox.set_size(
                     child.boundingBox.width,
                     child.boundingBox.height);
             } else {
-                workspaceBox.set_origin(this._workarea.x, this._workarea.y);
+                workspaceBox.set_origin(workareaX, workareaY);
                 workspaceBox.set_size(0, 0);
 
-                child.opacity = this._stateAdjustment.value * 255;
+                child.opacity = stateAdjustementValue * 255;
             }
 
             workspaceBox.scale(allocationScale);
@@ -657,7 +662,7 @@ var WorkspaceLayout = GObject.registerClass({
             layoutBox.set_size(width, height);
 
             const childBox = workspaceBox.interpolate(layoutBox,
-                this._stateAdjustment.value);
+                stateAdjustementValue);
 
             if (windowInfo.currentTransition) {
                 windowInfo.currentTransition.get_interval().set_final(childBox);